package presentation;

import java.awt.Dimension;
import java.awt.Font;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JLabel;

public class PStatusLabel extends JLabel implements Observer {
	private static final long serialVersionUID = 1L;
	private String prefix, unit;

	public PStatusLabel(String prefix, String text, String unit, int horizontalAlignment, 
			Font font,  int width, int height) {
		super(prefix + text + unit, horizontalAlignment);
		this.setPreferredSize(new Dimension(width,height));
		this.prefix = prefix;
		this.unit = unit;
		this.setFont(font);
	}

	@Override
	public void update(Observable obj, Object arg) {
		if (arg instanceof String[]) {
			this.setText(prefix + ((String[]) arg)[0] + unit);
			this.setToolTipText(((String[]) arg)[1]);
		}
	}
}